local sk__junwang = fk.CreateSkill {

  name = "sk__junwang",

  tags = { Skill.Compulsory, },

}



sk__junwang:addEffect(fk.EventPhaseStart, {
  name = "sk__junwang",
  anim_type = "control",
  frequency = Skill.Compulsory,
  events = {fk.EventPhaseStart, fk.EventPhaseEnd},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(sk__junwang.name) and target ~= player and target.phase == Player.Play and not target.dead and
      target:getHandcardNum() >= player:getHandcardNum() and not target:isKongcheng()
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:doIndicate(player.id, {target.id})
    local cards = room:askForCard(target, 1, 1, false, sk__junwang.name, false, ".", "#sk__junwang-give::"..player.id)
    room:moveCardTo(cards, Card.PlayerHand, player, fk.ReasonGive, sk__junwang.name, nil, false, target)
  end,
})
sk__junwang:addEffect(fk.EventPhaseEnd, {
  name = "sk__junwang",
  anim_type = "control",
  frequency = Skill.Compulsory,
  events = {fk.EventPhaseStart, fk.EventPhaseEnd},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(sk__junwang.name) and target ~= player and target.phase == Player.Play and not target.dead and
      target:getHandcardNum() >= player:getHandcardNum() and not target:isKongcheng()
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:doIndicate(player.id, {target.id})
    local cards = room:askForCard(target, 1, 1, false, sk__junwang.name, false, ".", "#sk__junwang-give::"..player.id)
    room:moveCardTo(cards, Card.PlayerHand, player, fk.ReasonGive, sk__junwang.name, nil, false, target)
  end,
})

return sk__junwang